﻿@{
    ViewBag.Title = "示范点列表";
    Layout = "~/Views/Shared/Layout.Mobile.cshtml";
}
<style>
    .content {
    width:100%
    }
</style>
<div class="page-group">
    <div class="page page-current" id="shifandian">
        <div class="content">
            <div class="buttons-tab">
                <a href="#tab1" class="tab-link active button">正在进行</a>
                <a href="#tab2" class="tab-link button">已完成</a>
                <a href="#tab3" class="tab-link button">已批准</a>
            </div>
            <div class="content-block">
                <div class="tabs">
                    <div id="tab1" class="tab active">
                        <div class="list-block" style="width:98%;margin-bottom:1px;margin-top:0px">
                            <ul id="tab1ul"></ul>
                        </div>
                        <div style="margin-top:10px">
                            <img style="height:14px;margin:10px;float:left;margin-right:5px" src="@TrialManagementTool.Helper.UrlHelper.alterContent("Images/Group.png")" />
                            <div>
                                <a onclick="location.href='@TrialManagementTool.Helper.UrlHelper.alterContent("TrialMobile/MainData?trialID=" + ViewBag.trialID )'" style="font-size:20px">添加示范点</a>
                            </div>
                        </div>
                    </div>
                    <div id="tab2" class="tab">
                        <div class="list-block" style="width:98%;margin-bottom:1px;margin-top:0px">
                            <ul id="tab2ul"></ul>
                        </div>
                    </div>
                    <div id="tab3" class="tab">
                        <div class="list-block" style="width:98%;margin-bottom:1px;margin-top:0px">
                            <ul id="tab3ul"></ul>
                        </div>
                    </div>
                </div>
                <a href="#" style="width:80%;margin:20px auto 30px auto" class="button button-big button-fill button-success" onclick="location.href='@TrialManagementTool.Helper.UrlHelper.alterContent("TrialMobile/TrialManagement")'">试验列表</a>
            </div>
        </div>
        <div style="position:absolute;right:0;top:100px">
            <a class="filterArea" onclick="loadPage()"> <img src="@TrialManagementTool.Helper.UrlHelper.alterContent("Images/fangan.png")" class="fangan" />  </a>
        </div>
    </div>

    <div class="page" id="purpose">
        <header class="bar bar-nav">
            <a class="button button-link button-nav pull-left back">
                <span class="icon icon-left"></span>
                返回
            </a>
            <h1 class='title'>示例方案</h1>
        </header>
        <div class="content" style="width:90%">

            @{var data = new ViewDataDictionary();

              data.Add("TrialGuideID", ViewBag.trialGuideID);
            Html.RenderPartial("Purpose", null, data); }
        </div>
    </div>
</div>
<script>
    function CreateElement(target, name, id) {
        var content = '<li class="item-content" ><div class="item-media"><i class="icon icon-f7"></i></div><div class="item-inner"  onclick=location.href=\'' + fixUrl("TrialMobile/ReportManagement?ID=" + id) + '\'><div class="item-title">' + name +
            '</div><div class="item-after"><span class="icon icon-right"></span></div></div></li>'
        $("#" + target).append(content);
    }
    function loadPage() {
        $.router.load("#purpose");
        init();
    }
    $.ajax({
        url: fixUrl("api/Trial/GetAllTrialSite"),
        cache: false,
        data: { id: '@ViewBag.trialId' },
        success: function (data) {
            $.each(data, function (index, value) {
                if (value.status == 2) {
                    CreateElement("tab2ul", value.Address, value.ID);
                } else if (value.status == 3) {
                    CreateElement("tab3ul", value.Address, value.ID);
                } else {
                    CreateElement("tab1ul", value.Address, value.ID);
                }
            })
        },
        error: function (data) {
            if (data.status == "401") {
                $.alert("当前用户未登录或登录超时");
            } else {
                $.alert('查询数据失败');
            }
        }
    })

</script>
